/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Imprimir.java
 *
 * Created on 29-abr-2013, 11:13:27
 */
package gui;

import controladores.ControladorPrincipal;
import io.Alumno;
import io.Juicio;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author NiCo
 */
public class Imprimir extends javax.swing.JFrame implements Printable {

    Object[] materias = new Object[12];
    ArrayList<Juicio> juicios;
    private int cantAlumnos;
    private List<Alumno> alumnos;

    /** Creates new form Imprimir */
    public Imprimir() {
        initComponents();
        this.setLocationRelativeTo(null);
        materias[0] = "I. Español";
        materias[1] = "Matemática";
        materias[2] = "Ingles";
        materias[3] = "Historia";
        materias[4] = "Geografía";
        materias[5] = "Biología";
        materias[6] = "C. Físicas";
        materias[7] = "Informática";
        materias[8] = "E.V.P.";
        materias[9] = "E.S.M.";
        materias[10] = "ECA";
        materias[11] = "Ed. Física";
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jYearChooser1 = new com.toedter.calendar.JYearChooser();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jRadioButton5 = new javax.swing.JRadioButton();
        jRadioButton6 = new javax.swing.JRadioButton();
        jRadioButton7 = new javax.swing.JRadioButton();
        jRadioButton16 = new javax.swing.JRadioButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jComboBox3 = new javax.swing.JComboBox();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jYearChooser2 = new com.toedter.calendar.JYearChooser();
        jRadioButton8 = new javax.swing.JRadioButton();
        jRadioButton9 = new javax.swing.JRadioButton();
        jRadioButton10 = new javax.swing.JRadioButton();
        jRadioButton11 = new javax.swing.JRadioButton();
        jRadioButton12 = new javax.swing.JRadioButton();
        jRadioButton13 = new javax.swing.JRadioButton();
        jRadioButton14 = new javax.swing.JRadioButton();
        jRadioButton15 = new javax.swing.JRadioButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Seleccionar grupo"));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Primero", "Segundo" }));
        jComboBox1.setSelectedIndex(-1);
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Curso");

        jLabel2.setText("Grupo");

        jLabel8.setText("Año");

        jYearChooser1.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jYearChooser1PropertyChange(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jYearChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(134, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(123, 123, 123))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8))
                    .addComponent(jYearChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setText("Datos");

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setText("1era. Evaluación");

        buttonGroup1.add(jRadioButton3);
        jRadioButton3.setText("1era. Reunión");

        buttonGroup1.add(jRadioButton4);
        jRadioButton4.setText("2da. Evaluación");
        jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton4ActionPerformed(evt);
            }
        });
        jRadioButton4.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
                jRadioButton4AncestorMoved(evt);
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        buttonGroup1.add(jRadioButton5);
        jRadioButton5.setText("2da. Reunión");

        buttonGroup1.add(jRadioButton6);
        jRadioButton6.setText("3era. Evaluación");

        buttonGroup1.add(jRadioButton7);
        jRadioButton7.setText("Todo");

        buttonGroup1.add(jRadioButton16);
        jRadioButton16.setText("Juicios Generales");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(43, 43, 43)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton1)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jRadioButton2)
                                    .addComponent(jRadioButton3)
                                    .addComponent(jRadioButton4))
                                .addGap(69, 69, 69)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jRadioButton16)
                                    .addComponent(jRadioButton7)
                                    .addComponent(jRadioButton6)
                                    .addComponent(jRadioButton5))))
                        .addGap(2, 2, 2))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jRadioButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton3))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jRadioButton5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton16)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton4)
                    .addComponent(jRadioButton7))
                .addGap(59, 59, 59))
        );

        jTabbedPane1.addTab("Grupo", jPanel2);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Seleccionar grupo"));

        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Primero", "Segundo", "Tercero" }));
        jComboBox4.setSelectedIndex(-1);
        jComboBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox4ActionPerformed(evt);
            }
        });

        jLabel3.setText("Curso");

        jLabel4.setText("Grupo");

        jLabel5.setText("Alumno");

        jLabel9.setText("Año");

        jYearChooser2.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jYearChooser2PropertyChange(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jYearChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel3)
                        .addComponent(jLabel9))
                    .addComponent(jYearChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jComboBox5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        buttonGroup2.add(jRadioButton8);
        jRadioButton8.setText("1era. Evaluación");

        buttonGroup2.add(jRadioButton9);
        jRadioButton9.setText("Datos");

        buttonGroup2.add(jRadioButton10);
        jRadioButton10.setText("Todo");

        buttonGroup2.add(jRadioButton11);
        jRadioButton11.setText("3era. Evaluación");

        buttonGroup2.add(jRadioButton12);
        jRadioButton12.setText("1era. Reunión");

        buttonGroup2.add(jRadioButton13);
        jRadioButton13.setText("2da. Reunión");

        buttonGroup2.add(jRadioButton14);
        jRadioButton14.setText("2da. Evaluación");
        jRadioButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton14ActionPerformed(evt);
            }
        });

        buttonGroup2.add(jRadioButton15);
        jRadioButton15.setText("Juicios Generales");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton9)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jRadioButton8)
                                    .addComponent(jRadioButton12)
                                    .addComponent(jRadioButton14))
                                .addGap(69, 69, 69)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jRadioButton15)
                                    .addComponent(jRadioButton10)
                                    .addComponent(jRadioButton11)
                                    .addComponent(jRadioButton13))))
                        .addGap(50, 50, 50))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jRadioButton9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jRadioButton12)
                            .addComponent(jRadioButton15)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jRadioButton13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButton11)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton14)
                    .addComponent(jRadioButton10))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Alumno", jPanel3);

        jButton1.setText("Imprimir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(164, 164, 164)
                        .addComponent(jButton1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton4ActionPerformed

    private void jRadioButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton14ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton14ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        PrinterJob job = PrinterJob.getPrinterJob();
        Paper hoja = new Paper();
        hoja.setImageableArea(0, 0, 612, 1008);
        hoja.setSize(612, 1008);
        try {
            juicios = null;
            if (jTabbedPane1.getSelectedIndex() == 0) {
                alumnos = ControladorPrincipal.getInstance().alumnosDelGrupo(jComboBox1.getSelectedItem().toString(), Integer.parseInt(jComboBox2.getSelectedItem().toString()), jYearChooser1.getYear());
                cantAlumnos = alumnos.size();
            } else {
                if (jTabbedPane1.getSelectedIndex() == 1) {
                    cantAlumnos = 1;
                }
            }
            // Diálogo para elegir el formato de impresión
            PageFormat pageFormat = new PageFormat();
            pageFormat.setOrientation(PageFormat.LANDSCAPE);
            pageFormat.setPaper(hoja);
            job.setPrintable(this, pageFormat);
            //pageFormat = job.pageDialog(pageFormat);
            if (job.printDialog()) {
                job.print();
            }
        } catch (Exception e) {
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed
        int anio = jYearChooser2.getYear();
        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
        Iterator<Integer> lista = ControladorPrincipal.getInstance().grupos(anio, jComboBox4.getSelectedItem().toString()).iterator();
        while (lista.hasNext()) {
            modelo.addElement(lista.next());
        }
        jComboBox3.setModel(modelo);
        jComboBox3.setSelectedIndex(-1);

    }//GEN-LAST:event_jComboBox4ActionPerformed

    private void jYearChooser2PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jYearChooser2PropertyChange
        if (evt.getPropertyName().equals("year")) {
            if (jComboBox4.getSelectedIndex() != -1) {
                int anio = jYearChooser2.getYear();
                DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                Iterator<Integer> lista = ControladorPrincipal.getInstance().grupos(anio, jComboBox4.getSelectedItem().toString()).iterator();
                while (lista.hasNext()) {
                    modelo.addElement(lista.next());
                }
                jComboBox3.setModel(modelo);
                jComboBox3.setSelectedIndex(-1);
            }
        }
    }//GEN-LAST:event_jYearChooser2PropertyChange

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        if (jComboBox4.getSelectedIndex() != -1 && jComboBox3.getSelectedIndex() != -1) {
            Iterator<Alumno> it = ControladorPrincipal.getInstance().alumnosDelGrupo(jComboBox4.getSelectedItem().toString(), Integer.parseInt(jComboBox3.getSelectedItem().toString()), jYearChooser2.getYear()).iterator();
            Alumno al;
            DefaultComboBoxModel modelo = new DefaultComboBoxModel();
            while (it.hasNext()) {
                al = it.next();
                modelo.addElement(al);
            }
            jComboBox5.setModel(modelo);
        }
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        int anio = jYearChooser1.getYear();
        DefaultComboBoxModel modelo = new DefaultComboBoxModel();
        Iterator<Integer> lista = ControladorPrincipal.getInstance().grupos(anio, jComboBox1.getSelectedItem().toString()).iterator();
        while (lista.hasNext()) {
            modelo.addElement(lista.next());
        }
        jComboBox2.setModel(modelo);
        jComboBox2.setSelectedIndex(-1);
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jYearChooser1PropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jYearChooser1PropertyChange
        if (evt.getPropertyName().equals("year")) {
            if (jComboBox4.getSelectedIndex() != -1) {
                int anio = jYearChooser2.getYear();
                DefaultComboBoxModel modelo = new DefaultComboBoxModel();
                Iterator<Integer> lista = ControladorPrincipal.getInstance().grupos(anio, jComboBox4.getSelectedItem().toString()).iterator();
                while (lista.hasNext()) {
                    modelo.addElement(lista.next());
                }
                jComboBox3.setModel(modelo);
                jComboBox3.setSelectedIndex(-1);
            }
        }
    }//GEN-LAST:event_jYearChooser1PropertyChange

    private void jRadioButton4AncestorMoved(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jRadioButton4AncestorMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jRadioButton4AncestorMoved
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton10;
    private javax.swing.JRadioButton jRadioButton11;
    private javax.swing.JRadioButton jRadioButton12;
    private javax.swing.JRadioButton jRadioButton13;
    private javax.swing.JRadioButton jRadioButton14;
    private javax.swing.JRadioButton jRadioButton15;
    private javax.swing.JRadioButton jRadioButton16;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton5;
    private javax.swing.JRadioButton jRadioButton6;
    private javax.swing.JRadioButton jRadioButton7;
    private javax.swing.JRadioButton jRadioButton8;
    private javax.swing.JRadioButton jRadioButton9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private com.toedter.calendar.JYearChooser jYearChooser1;
    private com.toedter.calendar.JYearChooser jYearChooser2;
    // End of variables declaration//GEN-END:variables

    private ArrayList<Juicio> recuperarJuicios(Alumno al, int reunion) {
        ArrayList<Juicio> juiciosRec = new ArrayList<Juicio>();
        for (int i = 0; i < 12; i++) {
            Juicio juicio = ControladorPrincipal.getInstance().juicioAlumno(al, materias[i].toString(), reunion, jYearChooser2.getYear());
            if (juicio != null) {
                juiciosRec.add(juicio);
            } else {
                juiciosRec.add(null);
            }
        }
        return juiciosRec;
    }

    @Override
    public int print(Graphics g, PageFormat f, int pageIndex) {
        SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yyyy");
        SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("HH:mm");
        if (pageIndex < cantAlumnos) {
//            try {
//                // Imprime "Hola mundo" en la primera pagina, en la posicion 100,100
//                Image img = ImageIO.read(new File("src/imagenes/Boletin calificaciones - interior.png").toURI().toURL());
//                g.drawImage(img, 0, 0, 1008, 612, null);
//            } catch (Exception ex) {
//            }

            if (jTabbedPane1.getSelectedIndex() == 0) {
                if (jRadioButton1.isSelected()) {
                    g.setFont(new Font("Eras Demi ITC", Font.PLAIN, 18));
                    g.drawString(jComboBox1.getSelectedItem().toString(), 747, 348);
                    Alumno al = alumnos.get(pageIndex);
                    g.drawString(al.getNombre(), 670, 382);
                    g.drawString(al.getApellido(), 670, 403);
                    g.drawString(jComboBox2.getSelectedItem().toString(), 691, 434);
                    g.drawString(String.valueOf(al.getNroLista()), 861, 434);
                    g.setFont(new Font("Tempus Sans ITC", Font.PLAIN, 24));
                    g.drawString(String.valueOf(jYearChooser1.getYear()), 731, 560);
                } else {
                    if (jRadioButton2.isSelected()) {
                        //primera evaluacion
                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                        Alumno al = alumnos.get(pageIndex);
                        g.drawString(al.getNombre() + " " + al.getApellido(), 100, 29);
                        g.drawString(String.valueOf(al.getNroLista()), 447, 29);
                        g.drawString(al.getPrevias(), 566, 29);

                        juicios = recuperarJuicios(al, 1);

                        Juicio juicio;
                        for (int i = 0; i <= 11; i++) {
                            juicio = juicios.get(i);
                            if (juicio != null) {
                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                if (juicio.getJuicio().length() > 53) {
                                    String s = juicio.getJuicio();
                                    int cont = 0;
                                    int renglon = 0;
                                    String aux[] = s.split(" ");
                                    ArrayList<String> lineas = new ArrayList<String>();
                                    while (aux.length >= cont + 1) {
                                        String cadena = "";
                                        cadena = aux[cont];
                                        while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                            cont++;
                                            cadena = cadena + " " + aux[cont];
                                        }
                                        cont++;
                                        lineas.add(cadena);
                                    }
                                    Iterator<String> it = lineas.iterator();
                                    while (it.hasNext()) {
                                        g.drawString(it.next(), 117, 81 + i * 31 + renglon * 9);
                                        renglon++;
                                    }
                                } else {
                                    g.drawString(juicio.getJuicio(), 117, 81 + i * 31);
                                }
                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                g.drawString(String.valueOf(juicio.getNota()), 308, 94 + i * 31);
                                if (i == 0) {
                                    g.drawString(sdf.format(juicio.getFecha()), 125, 547);
                                    g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                    g.drawString(String.valueOf(juicio.getJustificadas()), 145, 468);
                                    g.drawString(String.valueOf(juicio.getInjustificadas()), 203, 468);
                                    g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 268, 468);
                                }
                            }
                        }
                    } else {
                        if (jRadioButton3.isSelected()) {
                            //primera reunion
                            Alumno al = alumnos.get(pageIndex);

                            juicios = recuperarJuicios(al, 2);

                            Juicio juicio;
                            for (int i = 0; i <= 11; i++) {
                                juicio = juicios.get(i);
                                if (juicio != null) {
                                    g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                    if (juicio.getJuicio().length() > 53) {
                                        String s = juicio.getJuicio();
                                        int cont = 0;
                                        int renglon = 0;
                                        String aux[] = s.split(" ");
                                        ArrayList<String> lineas = new ArrayList<String>();
                                        while (aux.length >= cont + 1) {
                                            String cadena = "";
                                            cadena = aux[cont];
                                            while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                                cont++;
                                                cadena = cadena + " " + aux[cont];
                                            }
                                            cont++;
                                            lineas.add(cadena);
                                        }
                                        Iterator<String> it = lineas.iterator();
                                        while (it.hasNext()) {
                                            g.drawString(it.next(), 335, 81 + i * 31 + renglon * 9);
                                            renglon++;
                                        }
                                    } else {
                                        g.drawString(juicio.getJuicio(), 335, 81 + i * 31);
                                    }
                                    g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                    g.drawString(String.valueOf(juicio.getNota()), 526, 94 + i * 31);
                                    if (i == 0) {
                                        g.drawString(sdf.format(juicio.getFecha()), 339, 547);
                                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                        g.drawString(String.valueOf(juicio.getJustificadas()), 360, 468);
                                        g.drawString(String.valueOf(juicio.getInjustificadas()), 418, 468);
                                        g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 483, 468);
                                    }
                                }
                            }

                        } else {
                            if (jRadioButton4.isSelected()) {
                                //segunda evaluacion
                                Alumno al = alumnos.get(pageIndex);

                                juicios = recuperarJuicios(al, 3);

                                Juicio juicio;
                                for (int i = 0; i <= 11; i++) {
                                    juicio = juicios.get(i);
                                    if (juicio != null) {
                                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                        if (juicio.getJuicio().length() > 53) {
                                            String s = juicio.getJuicio();
                                            int cont = 0;
                                            int renglon = 0;
                                            String aux[] = s.split(" ");
                                            ArrayList<String> lineas = new ArrayList<String>();
                                            while (aux.length >= cont + 1) {
                                                String cadena = "";
                                                cadena = aux[cont];
                                                while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                                    cont++;
                                                    cadena = cadena + " " + aux[cont];
                                                }
                                                cont++;
                                                lineas.add(cadena);
                                            }
                                            Iterator<String> it = lineas.iterator();
                                            while (it.hasNext()) {
                                                g.drawString(it.next(), 552, 81 + i * 31 + renglon * 9);
                                                renglon++;
                                            }
                                        } else {
                                            g.drawString(juicio.getJuicio(), 552, 81 + i * 31);
                                        }
                                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                        g.drawString(String.valueOf(juicio.getNota()), 743, 94 + i * 31);
                                        if (i == 0) {
                                            g.drawString(sdf.format(juicio.getFecha()), 556, 547);
                                            g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                            g.drawString(String.valueOf(juicio.getJustificadas()), 577, 468);
                                            g.drawString(String.valueOf(juicio.getInjustificadas()), 635, 468);
                                            g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 700, 468);
                                        }
                                    }
                                }

                            } else {
                                if (jRadioButton5.isSelected()) {
                                } else {
                                    if (jRadioButton6.isSelected()) {
                                    } else {
                                        if (jRadioButton7.isSelected()) {
                                        } else {
                                            if (jRadioButton16.isSelected()) {
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
            } else {
                if (jTabbedPane1.getSelectedIndex() == 1) {
                    if (jRadioButton8.isSelected()) {
                        //primera evaluacion
                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                        Alumno al = (Alumno) jComboBox5.getSelectedItem();
                        g.drawString(al.getNombre() + " " + al.getApellido(), 100, 29);
                        g.drawString(String.valueOf(al.getNroLista()), 447, 29);
                        g.drawString(al.getPrevias(), 566, 29);

                        if (juicios == null) {
                            juicios = recuperarJuicios(al, 1);
                        }

                        Juicio juicio;
                        for (int i = 0; i <= 11; i++) {
                            juicio = juicios.get(i);
                            if (juicio != null) {
                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                if (juicio.getJuicio().length() > 53) {
                                    String s = juicio.getJuicio();
                                    int cont = 0;
                                    int renglon = 0;
                                    String aux[] = s.split(" ");
                                    ArrayList<String> lineas = new ArrayList<String>();
                                    while (aux.length >= cont + 1) {
                                        String cadena = "";
                                        cadena = aux[cont];
                                        while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                            cont++;
                                            cadena = cadena + " " + aux[cont];
                                        }
                                        cont++;
                                        lineas.add(cadena);
                                    }
                                    Iterator<String> it = lineas.iterator();
                                    while (it.hasNext()) {
                                        g.drawString(it.next(), 117, 81 + i * 31 + renglon * 9);
                                        renglon++;
                                    }
                                } else {
                                    g.drawString(juicio.getJuicio(), 117, 81 + i * 31);
                                }
                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                g.drawString(String.valueOf(juicio.getNota()), 308, 94 + i * 31);
                                if (i == 0) {
                                    g.drawString(sdf.format(juicio.getFecha()), 125, 547);
                                    g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                    g.drawString(String.valueOf(juicio.getJustificadas()), 145, 468);
                                    g.drawString(String.valueOf(juicio.getInjustificadas()), 203, 468);
                                    g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 268, 468);
                                }
                            }
                        }

                    } else {
                        if (jRadioButton9.isSelected()) {
                            // datos del alumno
                            g.setFont(new Font("Eras Demi ITC", Font.PLAIN, 18));
                            g.drawString(jComboBox4.getSelectedItem().toString(), 747, 348);
                            Alumno al = (Alumno) jComboBox5.getSelectedItem();
                            g.drawString(al.getNombre(), 670, 382);
                            g.drawString(al.getApellido(), 670, 403);
                            g.drawString(jComboBox3.getSelectedItem().toString(), 691, 434);
                            g.drawString(String.valueOf(al.getNroLista()), 861, 434);
                            g.setFont(new Font("Tempus Sans ITC", Font.PLAIN, 24));
                            g.drawString(String.valueOf(jYearChooser2.getYear()), 731, 560);
                        } else {
                            if (jRadioButton10.isSelected()) {
                            } else {
                                if (jRadioButton11.isSelected()) {
                                } else {
                                    if (jRadioButton12.isSelected()) {
                                        //primera reunion
                                        Alumno al = (Alumno) jComboBox5.getSelectedItem();

                                        if (juicios == null) {
                                            juicios = recuperarJuicios(al, 2);
                                        }

                                        Juicio juicio;
                                        for (int i = 0; i <= 11; i++) {
                                            juicio = juicios.get(i);
                                            if (juicio != null) {
                                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                                if (juicio.getJuicio().length() > 53) {
                                                    String s = juicio.getJuicio();
                                                    int cont = 0;
                                                    int renglon = 0;
                                                    String aux[] = s.split(" ");
                                                    ArrayList<String> lineas = new ArrayList<String>();
                                                    while (aux.length >= cont + 1) {
                                                        String cadena = "";
                                                        cadena = aux[cont];
                                                        while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                                            cont++;
                                                            cadena = cadena + " " + aux[cont];
                                                        }
                                                        cont++;
                                                        lineas.add(cadena);
                                                    }
                                                    Iterator<String> it = lineas.iterator();
                                                    while (it.hasNext()) {
                                                        g.drawString(it.next(), 335, 81 + i * 31 + renglon * 9);
                                                        renglon++;
                                                    }
                                                } else {
                                                    g.drawString(juicio.getJuicio(), 335, 81 + i * 31);
                                                }
                                                g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                                g.drawString(String.valueOf(juicio.getNota()), 526, 94 + i * 31);
                                                if (i == 0) {
                                                    g.drawString(sdf.format(juicio.getFecha()), 339, 547);
                                                    g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                                    g.drawString(String.valueOf(juicio.getJustificadas()), 360, 468);
                                                    g.drawString(String.valueOf(juicio.getInjustificadas()), 418, 468);
                                                    g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 483, 468);
                                                }
                                            }
                                        }

                                    } else {
                                        if (jRadioButton13.isSelected()) {
                                        } else {
                                            if (jRadioButton14.isSelected()) {
                                                //segunda evaluacion
                                                Alumno al = (Alumno) jComboBox5.getSelectedItem();

                                                if (juicios == null) {
                                                    juicios = recuperarJuicios(al, 3);
                                                }

                                                Juicio juicio;
                                                for (int i = 0; i <= 11; i++) {
                                                    juicio = juicios.get(i);
                                                    if (juicio != null) {
                                                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 8));
                                                        if (juicio.getJuicio().length() > 53) {
                                                            String s = juicio.getJuicio();
                                                            int cont = 0;
                                                            int renglon = 0;
                                                            String aux[] = s.split(" ");
                                                            ArrayList<String> lineas = new ArrayList<String>();
                                                            while (aux.length >= cont + 1) {
                                                                String cadena = "";
                                                                cadena = aux[cont];
                                                                while (cont < aux.length - 1 && (cadena.length() < 54 && cadena.length() + aux[cont + 1].length() < 54)) {
                                                                    cont++;
                                                                    cadena = cadena + " " + aux[cont];
                                                                }
                                                                cont++;
                                                                lineas.add(cadena);
                                                            }
                                                            Iterator<String> it = lineas.iterator();
                                                            while (it.hasNext()) {
                                                                g.drawString(it.next(), 552, 81 + i * 31 + renglon * 9);
                                                                renglon++;
                                                            }
                                                        } else {
                                                            g.drawString(juicio.getJuicio(), 552, 81 + i * 31);
                                                        }
                                                        g.setFont(new Font("Eras Light ITC", Font.PLAIN, 17));
                                                        g.drawString(String.valueOf(juicio.getNota()), 743, 94 + i * 31);
                                                        if (i == 0) {
                                                            g.drawString(sdf.format(juicio.getFecha()), 556, 547);
                                                            g.setFont(new Font("Eras Light ITC", Font.PLAIN, 15));
                                                            g.drawString(String.valueOf(juicio.getJustificadas()), 577, 468);
                                                            g.drawString(String.valueOf(juicio.getInjustificadas()), 635, 468);
                                                            g.drawString(String.valueOf(Math.round(juicio.getJustificadas() / 2 + juicio.getInjustificadas())), 700, 468);
                                                        }
                                                    }
                                                }

                                            } else {
                                                if (jRadioButton15.isSelected()) {
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                    }
                }
            }
//            if (rbtnFecha.isSelected()) {
//                g.setFont(new Font("Tahoma", Font.BOLD, 16));
//                g.drawString(sdf.format(dtpFecha1.getDate()), 112, 145);
//                g.setFont(new Font("Tahoma", Font.PLAIN, 10));
//                int j = 0;
//                for (int i = pageIndex * 26; i < dia.size(); i++) {
//                    if (j <= 25) {
//                        Llamado llamado = dia.get(i);
//                        g.drawString(llamado.getOperador().toString(), 54, 192 + (j * 15));
//                        g.drawString(sdf1.format(llamado.getHora()), 130, 192 + (j * 15));
//                        if (llamado.getCaso() != null) {
//                            g.drawString(llamado.getCaso().getNumeroCaso().toString(), 168, 192 + (j * 15));
//                            Nino_Adolescente nino = llamado.getCaso().getNino_adolescente();
//                            int indiceCaso = nino.getCasos().indexOf(llamado.getCaso());
//                            if (indiceCaso > 0) {
//                                g.drawString(nino.getCasos().get(indiceCaso - 1).getNumeroCaso().toString(), 217, 192 + (j * 15));
//                            }
//                        }
//                        if (llamado.getActualizacion() != null) {
//                            g.drawString(llamado.getActualizacion().getCaso().getNumeroCaso().toString(), 217, 192 + (j * 15));
//                            g.drawString("SI", 274, 192 + (j * 15));
//                        } else {
//                            g.drawString("NO", 274, 192 + (j * 15));
//                        }
//                        if (llamado.isInfo_asesoramiento()) {
//                            g.drawString("SI", 337, 192 + (j * 15));
//                        } else {
//                            g.drawString("NO", 337, 192 + (j * 15));
//                        }
//                        if (llamado.isInstitucion()) {
//                            g.drawString("SI", 392, 192 + (j * 15));
//                        } else {
//                            g.drawString("NO", 392, 192 + (j * 15));
//                        }
//                        if (llamado.isParticular()) {
//                            g.drawString("SI", 447, 192 + (j * 15));
//                        } else {
//                            g.drawString("NO", 447, 192 + (j * 15));
//                        }
//                        if (llamado.isBroma_otros()) {
//                            g.drawString("SI", 508, 192 + (j * 15));
//                        } else {
//                            g.drawString("NO", 508, 192 + (j * 15));
//                        }
//                        j++;
//                    } else {
//                        break;
//                    }
//                }
//                for (int i = 0; i < estadistica.size(); i++) {
//                    g.drawString(String.valueOf(estadistica.get(i)), 376, 608 + (i * 15));
//                }
//            } else {
//                if (rbtnPeriodo.isSelected()) {
//                    List<Llamado> lista = diasAux.get(pageIndex);
//                    g.setFont(new Font("Tahoma", Font.BOLD, 16));
//                    g.drawString(sdf.format(lista.get(0).getFecha()), 112, 145);
//                    g.setFont(new Font("Tahoma", Font.PLAIN, 10));
//                    for (int i = 0; i < lista.size(); i++) {
//                        Llamado llamado = lista.get(i);
//                        g.drawString(llamado.getOperador().toString(), 54, 192 + (i * 15));
//                        g.drawString(sdf1.format(llamado.getHora()), 130, 192 + (i * 15));
//                        if (llamado.getCaso() != null) {
//                            g.drawString(llamado.getCaso().getNumeroCaso().toString(), 168, 192 + (i * 15));
//                            Nino_Adolescente nino = llamado.getCaso().getNino_adolescente();
//                            int indiceCaso = nino.getCasos().indexOf(llamado.getCaso());
//                            if (indiceCaso > 0) {
//                                g.drawString(nino.getCasos().get(indiceCaso - 1).getNumeroCaso().toString(), 217, 192 + (i * 15));
//                            }
//                        }
//                        if (llamado.getActualizacion() != null) {
//                            g.drawString(llamado.getActualizacion().getCaso().getNumeroCaso().toString(), 217, 192 + (i * 15));
//                            g.drawString("SI", 274, 192 + (i * 15));
//                        } else {
//                            g.drawString("NO", 274, 192 + (i * 15));
//                        }
//                        if (llamado.isInfo_asesoramiento()) {
//                            g.drawString("SI", 337, 192 + (i * 15));
//                        } else {
//                            g.drawString("NO", 337, 192 + (i * 15));
//                        }
//                        if (llamado.isInstitucion()) {
//                            g.drawString("SI", 392, 192 + (i * 15));
//                        } else {
//                            g.drawString("NO", 392, 192 + (i * 15));
//                        }
//                        if (llamado.isParticular()) {
//                            g.drawString("SI", 447, 192 + (i * 15));
//                        } else {
//                            g.drawString("NO", 447, 192 + (i * 15));
//                        }
//                        if (llamado.isBroma_otros()) {
//                            g.drawString("SI", 508, 192 + (i * 15));
//                        } else {
//                            g.drawString("NO", 508, 192 + (i * 15));
//                        }
//                    }
//                    estadistica = estDias.get(pageIndex);
//                    for (int i = 0; i < estadistica.size(); i++) {
//                        g.drawString(String.valueOf(estadistica.get(i)), 376, 608 + (i * 15));
//                    }
//                }
//            }

            return PAGE_EXISTS;
        } else {
            return NO_SUCH_PAGE;
        }
    }
}
